package com.pms.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.pms.entity.Folder;
import com.pms.entity.Ideacomment;
import com.pms.entity.Project;
import com.pms.entity.Users;
import com.pms.service.FdService;
import com.pms.util.GetSession;

public class NewFolderServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		response.setCharacterEncoding("utf-8");
		request.getRequestDispatcher("/WEB-INF/newFolder.jsp").forward(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		request.setCharacterEncoding("utf-8");
		String name=request.getParameter("folderName");
		
		Project pro = (Project)GetSession.getSession(request).getAttribute("pro");
		String proid=pro.getPro_id();
		System.out.println(proid);
		Users user = (Users)GetSession.getSession(request).getAttribute("user");
		
		Folder fd=new Folder();
		fd.setName(name);
		fd.setProid(proid);
		fd.setUsreid(user.getUser_id());
		
		new FdService().save(fd);
		
		response.sendRedirect("fileServlet.jspx");
		
		
	}

}
